



const trank = []
let loginUser = {}
let score = 0;
let account = ''
let checkLength = 2;
let successCount = 0
let topChi = 0
let nowIndex = 0
let failCount = 0
let diffScore = -1
let mode = 0
let nowOrdata = {}
// const root_char = '疒疗宁成买今迅断扎丑扬与专蚌邦青堇勤缶窑卸魂魅忆交冥耒耗扪问盘版寐状北鼎鼐敌舍朱昧张弱义区丈驳寻尹录互虐印迎乐孵卯昴卿留湎妆氏纸聿律唐争剚妻芸充梳坏融贵飞居炎变严亦杰技吸卢眉假亚扣〇童眠黾绳抚既油杆视休棘亲坎须勿午乞穴空池敝唇振骨猾喎百丞刁孑沮县标礻礼荒曷死夙餐睿搞京亭膏狗申仕圣围祥美噗差幸芈扒平梁关善兴登祭失券容仔孔务复麸孜敲喜鼓息性添栅扁典丶玉刃春尺痕良即纠垃产船系细矛抒乡雍玄兹幽抖合令险论龠仄亻什豪缘汆耐咳官丸究抛拇永冰承没学益求聚鳏私勇悬惠毋毐贯苦开鼻艸啮需妨廿世燕共重垂歼姓卅带名岁卌舞芽吧夭亏仁晃耀庐所豸貌冂内冇凶周凹兕囧辆突犭独拓甫捕隔横勺包汇匡决巨吗汁截囊宏于戊咸臧越旺宰辩员驯州流巡粼夏咱冗风颃旦昔汩冒临矩矣优尬帐肆套召叨坚删帅渊万辨黎先允沈鸩顽戏或栈鹅烧墨嘿默代式武臼舀舆屎鬯鼬邋促跟街珩徒臣姬茸最阱塞佬孝相具直件特告挤齑餍喰饮果亩辈扉乏芝吊囗困亨披托东切殳设竹答监瓷瓯奴劲出逆发屯顿洛正此步徙捷甲匣办夯躺掌尝詹该队邓拂弟姊革勒依哀衤被农畏旅听丘兵乒乓袭丿么壬旋定疏兰漏雷角甬伯卑退扛难雁集拿打看段半击那判褎廷延旨呲化比以已己记凯降年尾毯扔凸汽氧禸禺噙仙巷祀吝斐洒贾朋肯丽夜然昨冫冻脊兆头彳待亍宋深龟阄兔冤免伍鱼鲜衡像顷頁寡耰历后急久玺庄禾种乘余鹿麒鸣岛赖辣柬乌呜章韵黯抓采捋乳卜补上卡叔军轩墼孤爬致室窒曹蛐驷罒罗尔当练少酋奠厨壹某柑其甚虎唬搋虑淦鉴针釜叩卫仓顾呵哥磨嘛躬殷亠市丹扇栩戳习'
let codeMode = false
let showText = '欢迎使用虎码在线练习程序，点击上面载文按钮进行载入剪贴板或者选文按钮载入预设的文章。'
// let showText = '测试'
let inputText = ''
let AllText = ''
let nowRow = 0
let MaxRow = -1
let errorCount = 0
let nextWord = ''
// 这两个放在异步请求的结果里调用
// initCounter(); // 初始化进度
// showQuest();
create()
let speed_time_out = null
let beginDate = new Date()
let nowData = null;
let diff
let rightCount = 0
let speed 
let inputCount = 0
nextWord = showText[0]
let logInfo = []
function create() {
    $('.show_text').html(showText)
    
}
function checkChar() {
    $('.box4').html(nowOrdata.diff.split('〔')[0])
    $('.box4').addClass('text-sm')
}
function trans(e) {
    let result = e.split('')

    res = []
    
    while(result.length>0){
        var index=Math.floor(Math.random()*result.length);
        res.push(result[index]);
        result.splice(index,1);
    }
    let s = ''
    for(let i =0; i < res.length;i++) {
        s+=res[i]
    }
    return s
}
function bichai(e) {
    let text = '疒疗宁成买今迅断扎丑扬与专蚌邦青堇勤缶窑卸魂魅忆交冥耒耗扪问盘牌爿寐状北鼎鼐敌舍朱昧张弱义区丈驳彐寻尹录互虐印迎乐孵卯昴卿留湎妆氏纸聿律唐争剚妻昙芸充梳坏融贵飞居炎兼孪严亦杰技吸卢眉假亚普扣〇童眠黾绳抚既油杆视休棘亲坎须勿午乞穴空池敝唇振骨猾喎百丞刁孑沮县标礻礼荒亾曷死夙粲睿搞京亭膏狗申仕圣围祥美噗差幸芈扒平梁关善兴凳祭失券容仔孔务复麸孜攴敲壴喜鼓息性添栅扁典丶玉刃春尺痕良即纠垃产船系细矛抒乡雍玄兹幽抖合令险论龠仄亻什豪遂缘入籴耐咳官丸究抛拇永冰承没学益求聚鳏私勇悬惠毋毐贯苦开戒鼻艸啮需妨廿世燕共重垂歼姓卅带名岁卌舞芽吧夭亏仁晃耀庐所豸貌冂内冇凶周凹兕泱囧辆突犭猝拓甫捕鬲隔横勹勺包汇匡决巨冯汁截囊宏戎于戊咸臧越旺宰辩员驯州鎏巡粼夏咱冗风颃旦昔曰汩冒临矩矣优尬帐肆套召叨坚删帅渊万辨黎先允沈鸩顽戏或栈鹅烧墨嘿默代式武臼舀舆屎鬯鼬邋促跟街珩徒臣姬茸嘬阱塞佬孝相具直件牡告挤齑餍喰饣饮果亩辈扉乏芝吊制囗困亨披托东切殳设竹答监瓷瓯奴劲出逆发屯顿洛正此步徙捷甲匣办夯躺掌尝詹讠谁队邓拂弟姊革勒依哀衤被农畏旅听丘兵乒乓袭丿么壬曳旋定疏兰漏雷角甩甬伯卑退扛难雁集拿扌打看段半击那判褎廴廷延旨呲化比以已己记凯降年毛娓毯扔凸汽氧禸禺噙仙巷祀吝斐洒贾朋肯丽夜燃昨冫冻脊兆头彳待亍宋深龟阄兔冤免伍鱼鲜衡像顷頁寡耰历卮急久玺庄禾种乘余鹿麒鸣岛赖辣柬乌呜章韵黯抓采捋乳浮卜补上卡叔军轩車墼孤爬致室窒曹蛐驷罒睾尔当练少酋奠厨壹某柑其甚虎唬搋虑淦鉴针釜叩卫仓顾呵哥磨嘛躬殷亠市丹扇栩戳习'
    if (e == 0) {

        loadArical(text)
    }else {
        loadArical(trans(text))

    }

}
function sanma() {
    let text = '己鱼骨乌甲毛禾龟乡兔虎毋耒甫鬲臼氏隹戊黾卯曰聿芈缶丿丶彳亻卅卌〇囗罒冫亠礻衤冂殳勹疒饣讠扌彐廴爿攴壴頁車'
    loadArical(trans(text))

}
function huanjie() {
    let text = '忌舌祭券赔湿寸蒋宪尸纠役贡拼割侠炼绩昌浑峡籍逊惟聪爬趁锐撤础遥呵缝腹盯渔稿肿吕恋彭啥税弯遣抛奴枚晶豆滋抑盐障肥译溜哀疏瑟躺汪贾揭赢骂喷粹贸羞削挣歇柴菌扩拳汇斥娇鸿爸症湾辽寺怔曼嘉吩肝愚煞鉴踏汽岗刊廉沃扭添殖溃祸侍阔岩谨怖斩魏债勾疯拦虫邓弥矿瞬趋惩雕驾儒郁履晋裂煤宏逆贤孝夸勃猫椅屠桂患恭邀衡僧乙迁凯闯乾瞪漠缠耗罩砍贺桃苗坛窝艇披殿欠娃霸牲涂航秩怜嘛购瘦蛮沟岳爵盟扁抚葛誉厌薛牢艾萧筹慎疲纽恼腐粒崇耀蔡玻茫爹诊袁幼辩艰催赫霍昆坡植丘俄键潘碗喘晃雇侦剂卿俩腊姜肌盾胞兽肚傻纹绳痕歼扣菲赋庙挨辅撒狱箭艘乳酸冯脏订赴牧漂遂鹰串舱闷丑届姿润曰绘玄汗嫁捉娜跌柄惧磁哲偿频吨幻慕宅玛堡浅炸莱蛇循猎挡荷仆戒掠档袭伐欺滴刷舰铜挖疼卢蒂丛售币埋屏肖弓迪牵拟曹碧岂贷肤驱斤狼帽婴唉仓乏勉租搬册赌赐黎吓姊励寂吞巫粮贪逻储猪帅熊耕诱械妥碍炮液御辑叛哦脉龄玲聊糖郭鞋咬阁翼仗悠堪践澳旨劫墓愁唇契悬爆烂梯吼邪伪浩邮哼隶雾苍扔穆拨媒躲埃恒呈兹矮鼠衰嫌蜂丫朵敲齿胁燃皱辖慈炎柏晴傲跪贼妖悔矛饿弗狐柱疗综钻驶猜缴暖巡抖帕狠迈驻凶瓜庞睁戈桑卧笼慌轰押吾叙宙羽陵奸鹏仔估扇卓姆擦糟胖署仇廷遵喂核夹颤嘿哩袖穴悟捷涨搜亿惨扯愤昏摄牺阅奏稀援敦辨'
    loadArical(trans(text))

}
function xuanjie() {
    let text = '颁咸览裹俘钩诈淫挫骚涵愉崖鲍洒脖嚷肺棍氧诀佐竖姨滥斋膝溢猴寓嘶倡锡畏泣坟兜颠逝址冤荆蒲兆亩哑泄蓬耸碑丐俺冥崩俯臭脊倚鹤鸦辱蠢乞钓窜绵翠妮疫玫吻函搏绢勋秃胃屡浙恕囚昔莉谱卵哄瘤轩彪攀寨蔽耽拓姻谦窄剪腕膀孕拆荐靖酷晰昧亭寡舶娶艳瞄颈歧浦瓷砸逸泊愕薪媳胳炉蜜哨讼旬株厦宴嘻猿囊僚裤顽拐翁掏吏雀妨肢嘲咕歪魄婉拂甫堵塑嘱昭藤棺倘辟诞侨纲凑眨啸肠芬刮汝嗓铃茅榜撰灌葬渴筋撕矣匈谭慨棚竭鹿雁屁禄郊骄摧咐链框尉棒遮陌棵躬叠鸭扮丸愧阎崔漆菊鹅浴袍逮哇哗赚掀擅霜趟吟诡雌妃赠耿摘弊铭栏匠壶廊弦阐饶蓄聘庸萄姚巢淋拘冀坎甩盲浸泡驳淮宠豹朴蒸罐挽巷筒窃饲猩铸卑畜徽衙咖乖耍棉焰爽讽漏焚躁辣驰捧桩宰裸萍瞒祈矩滩渠劣杭夷粘撑焉夕媚琼爪讶轨谊盼殷霞坠栽逢蜀纱裕沾陕旺兔舟辰晕腔杆塌擒填裙挪嫂掘眠吁巾脾厘桶衍翅疆翰摔膜溶踢帆搁账肆哎轿衷罕勿歉怯逗氛茂菩厢伞柜狭芝恳谅侄虏寇泼腺喉憾抹卜剥鞭硕饱葡螺厨琳舅篮毅呜虹涛绑钦耻懒吵骇咳秒饥陡咒翔匪稽妄凄仑钉蹲携砖倦吊僵贱冻绣痴卒谎踩摊杖拱昂锅璃窑盒煌禀岭衔畅驴渊枯咽恍壳宛愣冈捞蝶戚饼湘惶叮鄙拢龟脆盈帘刹骤鼎豫抄贞捏渗喻溪尴垄劈巩棋胶捐甜纤狡舆胀盆尿笨脂誓酬芒卸滞惹炭禅癌胎叉坑悦衫躯狮聂斑瞎'
    loadArical(trans(text))

}
function dijie() {
    let text = '襟汹驼觅坝澜盏胧嚣糕羡惭遏敛颓蚊唾锻衬钮灼蔓镑梨锣栖蚂姥赎挠帖榴绞珊扛暇铅弘崭剖琉诫扼缆淳寝钥俭褐绽炒迭浊澡瞅敞啼彬嫩鄂圾兑竿啤熄勘毯暮瓣浆旱峨骏砂淹拯逛旭哺卦铲咋纺尧戎侣彰坊蝉苟鳍庐簇腻苹绅撼邑讳绸烛刁揣搅粥煽沼燥嗡粟矫蹄堕沛絮凰笛捂乍梢敷萌塘懊芙娥尬畴涡轴葫渺茵晌喧扒匿枕逞侥颂孽枣烤梗镶烁韵掐宦灶莹硝钞虐锥厕缕晦晒虾沮碟缚拙疤萝讥拣佑醋揪烫谬馨譬煮碌匣膛蚀魅揉瘫窥丙斧碳焕茎嫉溅墟琢揽篷禽搓泳熬淌毙桐棕绰莺矢枢鞠垫嚼拧蓉钧栓苛莽蛙蜘沦溯梳诬呻哉嵌豁煎肘狸碱刃冉顷醇峻辐奢涯凳沪悼痒踱黯僻藉憋橡魁哮棠啪盔裳杉蛛捣酌涩凛萎翘隙砰吱谴贿舵叨肾伺畔庇窍睹瑰冶庶馈髓喇霉绒吭泌屑庚缸跋胚扳垃屯掷潭禹幢蔬坪崎伶拽咧庵娟滔匕熏葱怠啡垒蚁捡迂岔熙崛聋菱傍潇谜粪寞纬腥稚旷祷苑逾憎擎沐桨帜昼慷堤哆骆沸撇妆坤鲸荫蝴杏弧梭牡霄贮泻徘俏鳞檀栋琐蹦熔窘隋陋迄沧鸽暑哟膏佣怡栅矗婶稻贬诵磷呐壤澄斟炕滨凹忿惕匙嚎簿眯谐秉嘀宵甸墅戳搂膊棱缀呕删枫锤柬奠赦缅涕蕴藻匀淑槽凿靴缔栗峭芦霎蚕妓捆悍膨歹叭斌磕氢磅颊娱腮谍淘筷硫夭咨棘芽眷凸酿募趴沫犬樱贩辜侮谣嗽窟懈叩噪浏芯椎嗅皓蔑朦瞻拇阀沁礁蝇浇灿嗜屿绷朽稼挟汁枉剿驯垮窒蜡颖妒蹈蹬廓'
    loadArical(trans(text))

}
function tianjie() {
    let text = '搔鳖汞荔薯抡坯悴恤巳绚赣撵柑玷锚赁捶痰烹贰璧抒唠刨秽韧褪疮寅榕槐趾咪谚禾酱迢袄屹箫榄嗦狰彤肮睐戊囱芹酪螃卯埠酗酝撬筐耙鹃樟叁柠拗芜狈镐捻澎篡榨饺捍蝠汛曝匾蚓薇褥懦帚幌秤酣荤唧蟋咄噩榔殉滤灸蛤眶橄痹拴羹涤胰啰亥洼蔼孵祟掰蒜钠琅屎乓捅疟豌褒唬柿瓤袱紊蝎窿侈涮峦睬桦痘菠寥搀藐捌颅惋掺锹撮铛锰炊纫聆簸蟀苔稠碘亢馋蔚挚闺镀垦鲫淀漓硅砚倔椭柒蛀泵烘吆闰舀汰茉赂鸵惦啃粱钾瞭桔巅俐壬讹赃杠轧吮疙肛葵馒腋窖捎碾翩藕筛徙砌帷叼肪靶缰铝酥隧渤贻摹驮渝坷籽雳肴鲨撩鳄弛馁涝躏卤揍悯拷糙蜗钙锯溉濒谤闽饵苞壹矾霹跺茸缭炬澈叽痪曙蛾榆臀猬徊缤镰渲瞩脐咙笙氮绊蚪兢涣茁氨呛蚣瘸秧氯蕉跷绎吝堰鞍惰跛赡荧茧跤箕捺癸粤蜒瞳篱祀蹋鬓砾殃皂蠕拄馏挎睦袜菇淆蝗掂鸳甥晾蚤拎泞穗楷蜓锄褂漾脓竣豚犀誊蚌辙羚椒咏涧蜕焊脯鸯蝙瘩忱圃瓢溺筝疚韭瘟缎臊蕾恃篓芋漱糯沥垛瘪雏鲤骡芥剔陨淤癣舔抠痊酵蜈蹭箩炫衅皿鹦疹雹辫蟹悖憨簧磊瑙揩橘臼茄椰隅渣蟆秆酉谆猖黔蹂钳玖垢戌糠芭梧耘洽踊诲栈埂鹊锈夯赘隘喳豺笋祠缉椿睫拌憔馍鹉擂蘑铐馅盹囤羔驹屉皖狞梆湃肇肋惫蚯犁唆秸蝌乒啄辗蕊岖苇氓婪蜻檐佃橱橙沽鸥勺冗诽锌吠瀑萤墩瘾靡筏毡闸嘹茬钝蔗檬痢殴剃娄巍婿拭烙猾恬卉畸唁滇偎槛'
    loadArical(trans(text))

}
function hu1jian(e) {
    let text = '都得也了我到的为是行来说中一就道人能而可和不要如在大'
    if (e == 0) {

        loadArical(text)
    }else {
        loadArical(trans(text))

    }

}
function hou500() {
    let text = '珠鼓阶孔徐固偏陆诸遗爷述帝闭补编巨透弄尤鲁拥录吴墙货弱敌挑宽迹抽忍折输稳皇桌献蒙纷麻洗评挂童尊舍唯博剧乃混弹附迟敬杯鱼控塞剑厚佳测训牙洞淡盛县芳雅革款横累择乘刺载猛逃构赵杜庆途奔虎巧抗针徒圆闪谷绍聚额健诚鲜泪闲均序震仿缘戴婚篇亡奶忠烦赛闹协杰残懂丹柳妹映桥叹愈旅授享暴偷蓝氏寒宜弃丰延辈抢颜赞典冒眉烧厂唱径库川辞伴怒型纯贝票隔穷拜审伦悲柔启减页纵扫伟迫振瑞丈梁洲枪央触予孤缩洛损促番罢宋奋销幕犹锁珍抬陪妙摸峰劲镜沈夺昨哭讯貌谋泰侧贫扶阻贴申岸彼赏版抵泽插迅凭伊潮咱仙符宇肩尝递燕洁拒郎凝净遭仪薄卡末勒乌森诺呀壮忧沿惯丢季企壁惜婆袋朗零辛忆努舒枝凤灭韩胆灰旦孟陷俗绕疾瞧洪甲帐糊泛皆碰吹码奉箱倾胸堆狂仲圈冬餐厉腿尖括佩鬼欣垂跃港骗融撞塔紫荡敏郑赖滑允鸟课暂瓦祥染滚浮粗刑辆狗扑稍秦扎魂岛腾臣琴悉络摩措域冠竹殊豪呆萨旋喊寄悄倍祝剩督旗返召彻宾甘吐乔腰拔幅违详臂尺饮颗涉逼竞培惠亏叔伏唤鸡邻池怨奥侯骑漫拖俊尾恨贯凌兼询碎晨罚铺浓伍宿泉井繁粉绪筑恢匹尘辉魔仰董描距盗渡勤劝莲坦搭挺踪幽截荒恰慧邦颇焦醉废掩签丧灾鼻侵陶肃裁俱磨析奖匆瓶泥拾凉麦钢涌潜隆津搞蛋奈扰耐傅锦播墨偶捕惑飘屈鸣挤毁斜啦污赤慰饰锋覆汤寿跨羊'
    loadArical(trans(text))

}

function qian500(e) {
    let text = '的一是了不在有个人这上中大为来我到出要以时和地们得可下对生也子就过能他会多发说而于自之用年行家方后作成开面事好小心前所道法如进着同经分定都然与本还其当起动已两点从问里主实天高去现长此三将无国全文理明日些看只公等十意正外想间把情者没重相那向知因样学应又手但信关使种见力名二处门并口么先位头回话很再由身入内第平被给次别几月真立新通少机打水果最部何安接报声才体今合性西你放表目加常做己老四件解路更走比总金管光工结提任东原便美及教难世至气神山数利书代直色场变记张必受交非服化求风度太万各算边王什快许连五活思该步海指物则女或完马强言条特命感清带认保望转传儿制干计民白住字它义车像反象题却流且即深近形取往系量论告息让决未花收满每华业南觉电空眼听远师元请容她军士百办语期北林识半夫客战院城候单音台死视领失司亲始极双令改功程爱德复切随李员离轻观青足落叫根怎持精送众影八首包准兴红达早尽故房引火站似找备调断设格消拉照布友整术石展紧据终周式举飞片虽易运笑云建谈界务写钱商乐推注越千微若约英集示呢待坐议乎留称品志黑存六造低江念产刻节尔吃势依图共曾响底装具喜严九况跟罗须显热病证刚治绝群市阳确究久除闻答段官政类黄武七支费父统'
    if (e == 0) {

        loadArical(text)
    }else {
        loadArical(trans(text))

    }
}
function ming500() {
    let text = '渊卿胤龠绗珩街衍衡衔衙衢哀袤褒衰蓑簑襄攘壤镶瓤囊囔馕蠹莫暮幕墓慕蓦募摹寞模漠膜馍蟆貘谟亢坑杭航肮炕吭伉沆仓抢枪呛怆沧舱跄创苍疮共哄供洪拱烘巷港粪龚巽馔撰殿臀癜壬任荏凭赁恁衽妊饪淫婬霪廷挺蜓艇铤庭霆延诞涎蜒筵冉再蚺苒篝媾必泌秘馝谧宓蜜密峰锋蜂烽逢缝蓬篷降绛隆窿戎贼绒戒械诫武赋斌鹉以似拟娰代玳贷袋黛岱戈找划伐阀筏戋线浅贱溅残践栈饯盏笺或域蜮阈夏厦戛嘎兀杌尧烧绕浇娆桡挠晓侥跷骁翘刍㑇急稳隐瘾煞趋绉诌雏邹妥馁绥挼荽孚乳浮俘蜉捋殍酹真镇慎缜嗔阗瞋滇稹颠巅癫直值殖植置矗吉洁桔诘佶拮秸黠颉撷袁辕猿周绸凋稠碉惆啁倜鲷雕步涉频濒颦徙屣陟知智痴蜘踟式试拭轼赢嬴羸少抄秒炒钞砂沙莎省痧娑裟鲨挲眇渺缈汶浏贮伫享淳醇谆椁敦墩礅郭廓鹑亨哼烹亭停婷盲膏肓罔惘蜀镯躅勺约哟钓灼妁酌尥趵芍匀均筠钧韵药旬询绚殉峋洵徇荀留溜馏镏熘遛瘤聊卯仰抑铆柳迎昂幺幻幼呦拗坳蚴黝窈暴爆瀑曝率摔蟀玄炫眩弦泫畜搐蓄卑脾牌啤碑埤婢睥俾裨稗捭尹伊吚咿君郡裙笋窘敕整嫩漱嗽簌蔌难摊滩瘫隽携镌雉薙雁赝鹰膺焦瞧憔礁樵醮蘸蕉劁崔催摧瞿矍攫隼榫隺鹤榷霍嚯藿珍诊殄餮轸胗疹谬缪戮勠寥廖半胖拌伴绊畔冸叛判益溢缢隘盈楹电奄掩俺淹腌庵阉鹌今吟妗黔含晗馠娢焓念捻谂稔唸贪衾岑涔颔令零苓领邻拎怜伶泠岭玲聆羚呤翎瓴囹夬快筷块决缺诀抉袂玦央映怏秧殃泱鞅盎鸯'
    loadArical(trans(text))

}
function zhong500() {
    let text = '府查般斯倒突号树拿克初广奇愿欢希母香破谁致线急古既句京甚仍晚争游龙余护另器细木权星哪苦孩试朝阿队居害独讲错局男差参社换选止际假汉够诉资密案史较环投静宝专修室区料帮衣竟模脸善兵考规联团冷玉施派纪采历顾春责夜画惊银负续吗简章左块索酒值态按陈河巴冲阵境助角户乱呼灵脚继楼景怕停铁异谢否伤兰置医良承福科属围需退基右速适药怀击买素背岁土忙充排价质遇端列印贵疑露哥杀标招血礼弟亮齐穿脑委州某顺省讨尚维板散项状追笔副层沙养读习永草胡济执察归富座雨堂威忽苏船罪敢妇村著食导免温莫掌激慢托胜险寻守波雷沉秀职验靠楚略族藏丽渐刘仅肯担扬盘唐钟级毛营坚松皮供店饭范哈赶吧雪斗效临农味恶烟园烈配杂短卫跳孙曲封抓移顿律卖艺旧朋救防脱翻划迎痛校窗宣乡杨叶警限湖软掉财词压挥超屋秋跑忘馆暗班党宗坏技困登姐预耳席梦朱组旁份禁套亚益探康增诗戏伯晓含劳恩顶君庄谓付田毕纸研虚怪宁替犯灯优您姓例丝盖误架幸隐股毒娘占智佛床米凡介征彩演射祖欲束获舞圣伙梅普借私源镇睡缓升纳织歌宫概野醒夏互积街牌休摇洋败监骨批兄刀网率庭熟创访硬仁菜丁绿牛避阴拍雄秘缺卷姑尼油恐玩释遍握球降虑荣策肉妈迷检伸欧攻练育危厅啊睛摆茶勇判材抱亦妻吸喝趣嘴逐操午吉浪轮默毫冰'
    loadArical(trans(text))

    
}
function rumo() {
    let text = '昶氇槱薢赟鹪圜鹬璩魈樾疐漦灏慭羼虢黪澶鼒瓻嶷鞫蝥躜䗛檗榃礅摴螟欂勚缱鬏皤曩橼醮蕹鲴镲鹳罍雠螈鞡遘衠鹯鬒勰鞨㻬遹赪郄霭镝鳊戤鲽寮纂觱耪鼯棨曌瞠蘅鲼觿墼鳙爨瀵耱㠇簠飏廑篥鲮鹔澧蟮禤斝澭觌楝镠彝颢妫斶躔罽釐襻酆螵垩铏魋黧蟪齉颡徼蘩廪勔辚隳嫠饕鞧潲㬎麈鼷瘿巉藁鬷璘厣滘甗镡瀛擿攫棻醯劓薷黠鏊噻儳豳歙蠲澥嘏镤阒髎濮謇廨菝禋鬯繄褫螬獬黉㘎麝燮璞躞瞰斠蹩螅攥鳏檄缮癃剋嫕濉鳀甏孅耩磡㽏穰蘘疐黹哿瘴鞬篼踅羝糒镛癔爝醪鹾飙皞黡衢燧攮醑翮塱㙦胤璺髽谿髅颟饔黻鞴灞躇暾戣蠖膙黼瘗醴窳巇趱螽纛爇磴燠褰粜欿僎蹇髂彟鹩瀣蘧馕邂燔颞蕻醛燹鳢藿䗴逴襞鬶蹀氍齇貆繇魍爚瘵鄘醢醭儇艴蹽馘鳟蹾镵鹮瀍髹䲢薮癞簟蠹镩鹙畬鼽鼹磲羲癜亳嚆嬖訇篦鄹瀱猺蟊髑魉缵簝鼍歅臌鬈隰樨醾馗鬘暅醚鞲阘酂璱髫瞽厖甑嚚鲺蟛盦簰耰蟠癯襫縠敩鐾酅葑鳎髀銎疃燊墈鄠镪螭甓糵髢霅蔸瀔翱翯鲻㮾罅鞯氆壅薤㬊橛犨鲳嬗缯谼橐劄嶲艟蟥憙鳐髃薰旞曛矍夔蒇劐籁爟濠㬚瓘蔊蠡豮蘖氅嚄霨葜缬爔囔麑蟒獴鬃廒樵麖镬麇裛髻殪蟏糌禳龋槃夐澂聱㸆藜鼋龠螫瓒濂镢缳蘸鬻薹䗪鳓窬屦鬟墘攉髭皭黢儡圙藠酃檠簋郿蠓橇飔簖鋈戆鲝螳鼗牻亸籀戭蹿翾縻瘰貔鹒襁暵艨缞乸篪鹎蔈薿嚭罾䴗髋畿嶍獾藦蕺懿亹樽潟薏鼢鞣镦礓薨濡鳘'
    loadArical(trans(text))

}
function lrxu() {
    let text = $('#message_text').val()
    text = trans(text)
    $('#message_text').val(text)
}
function checkCode() {
    let tstring = nowOrdata.diff.split('〔')[1]
    $('.box3').html(tstring.substr(0, tstring.length-1)+'<br>' + nowOrdata.code
        
    )
    $('.box3').addClass('text-sm2')
}
function stopSpeed() {
    if (speed_time_out != null) {
        clearInterval(speed_time_out)
        speed_time_out = null
        $('#speed').html('')
        inputCount = 0
    }
}
function loadArical(e) {
    nextWord = e[0]
    checkChar()
    checkCode()
    stopSpeed()
    $('#backspace').html(errorCount)
    $('#cnumber').html(nowRow+1)
    $('#input').val('')
    if (!codeMode) {
        $('.show_text').html(e)
        $('#mpreocess').html(100)

        showText = e
    }else {

        AllText = e
        MaxRow = Math.trunc(e.length/10 ) 
        nowRow = 0
        $('.show_text').html(e.substr(0, 10))
        $('#mpreocess').html((nowRow+1 / MaxRow * 100).toFixed(2))
        showText = e.substr(0, 10)
    }

}
function checkChar() {
    axios.get(host + '/dic/'+nextWord).then(res=>{
        nowOrdata = res.data.data
        let templist = nowOrdata.code.split(' ')
        codeList = templist
        if(templist[1]) {
            ecode = templist[1]
        }
        if(templist[0]) {
            fcode = templist[0]
        }
        if(templist.length == 1) {
            fcode = templist[0]
        }else if (templist.length == 2) {
                ecode = templist[0]
                fcode = templist[1]
        }
        let tstring = nowOrdata.diff.split('〔')[1]
        tstring = tstring.replace(/\s*/g,"");
        $('.box4').html(nowOrdata.diff.split('〔')[0] + '<br>' + tstring.substr(0, tstring.length-1))
        $('.box4').addClass('text-sm')



    })
}

function checkCode() {
    axios.get(host + '/dic/'+nextWord).then(res=>{
        nowOrdata = res.data.data
        let templist = nowOrdata.code.split(' ')
        codeList = templist
        if(templist[1]) {
            ecode = templist[1]
        }
        if(templist[0]) {
            fcode = templist[0]
        }
        if(templist.length == 1) {
            fcode = templist[0]
        }else if (templist.length == 2) {
                ecode = templist[0]
                fcode = templist[1]
        }
        $('.box3').html(nowOrdata.code)
        $('.box3').addClass('text-sm2')



    })
}
function nextRow() {

    nowRow++
    if (nowRow >   MaxRow) {
        alert('练习结束')
        $('#input').val('')
        stopSpeed()

        $('.show_text').html('欢迎使用虎码在线练习程序，点击上面载文按钮进行载入剪贴板或者选文按钮载入预设的文章。')
        return
    }
    $('#backspace').html(errorCount)

    let tempstring = AllText.substring(nowRow*10, (nowRow+1)*10)
    $('#mpreocess').html((nowRow / MaxRow * 100).toFixed(2))
    showText =tempstring
    $('.show_text').html(showText)
    $('#cnumber').html(nowRow+1)
    $('#input').val('')
    stopSpeed()

}
function reRow() {
    stopSpeed()

    showText = trans(showText)
    $('.show_text').html(showText)
    $('#input').val('')

    $('#backspace').html(errorCount)


}
function addLog() {
    let _logInfo = logInfo
    _logInfo.push({
        num: nowRow+1,
        speed: speed,
        time: (diff/1000).toFixed(2),
        backCount: errorCount
    })
    let log_body = ''
    for (let i = 0; i < _logInfo.length; i++) {
        $('.log_item')
        log_body += `
        <div class="log_item">
        <div>${i+1}</div>
        <div>${_logInfo[i].speed}</div>
        <div>${_logInfo[i].time}</div>
        <div>${_logInfo[i].backCount}</div>
      </div>
        `
    }
    _logInfo = _logInfo.reverse()
    $('.log_body').html(log_body)
}
function loadText() {
    let text = $('#message_text').val()
    $('#exampleModal').modal('hide')
    loadArical(text)
}
let keydown_now = -1
$("#input").keydown(function(event){
    keydown_now = event.which
    if (keydown_now == 8) {
        errorCount++
        
        $('#backspace').html(errorCount)
    }
});

let timer = null
function inputChanged() {
    // 只要有空格就是错的
    let value = input.value
    tempSpanText = ''
    let lastWord = value.substr(value.length-1, value.length)
    // console.log(value.substr(value.length-1, value.length))
    if (/^[a-zA-Z]+$/.test(lastWord)) {

        return
    }
    let i = 0
    inputCount++
    if (speed_time_out == null) {
        beginDate = new Date()

        speed_time_out = setInterval(()=>{
        nowData = new Date()
        diff = nowData - beginDate
        speed = (inputCount*60 / (diff / 1000)).toFixed(2) 
        $('#speed').html(speed)
    }, 10)
    }
    $('.box4').html(`<div class="title">拆分</div>`)
    $('.box4').removeClass('text-sm')
    $('.box3').html('<div class="title">编码</div>')
    $('.box3').removeClass('text-sm2')
    rightCount = 0
    for (i = 0; i < value.length; i++) {
        if (value[i] == showText[i]) {
            tempSpanText += `<span style="background-color:#707070;float;">${showText[i]}</span>`
            rightCount++
        }
        if (value[i] != showText[i]) {
            tempSpanText += `<span style="background-color:#ff3030;float;">${showText[i]}</span>`

        }
    }
    if (value.length >= showText.length) {
        addLog()
    stopSpeed()

        if (codeMode ) {
            if (errorCount == 0 && rightCount == i) {

                nextRow()
            return

            }

            else {
                errorCount = 0
        $('#backspace').html(errorCount)

                reRow()
                return

            }

        }
    }

    tempText =tempSpanText + showText.substring(i, showText.length)
    nextWord = showText[i]
    if (timer) {
        clearTimeout(timer)
      
    }  timer = setTimeout(()=>{
            checkChar()
            checkCode()
            timer = null
        }, 1000)



    $('.show_text').html(tempText)

}

function initCounter()  //初始化进度，所有字根初始学习进度为-1
{
    for (let i = 0; i < total; i++) {
        count[i] = -1;
        index[i] = i;
    }
    nowIndex = 0
}
function changeMainRoot(e) {
    // if (codeMode) {
    //     $('#diff').html('分段')
    // }else {
    //     $('#diff').html('全文')

    // }
    if (e == 'diff') {
        $('#all').removeClass('btn-danger')
        $('#all').addClass('btn-info')
        $('#diff').addClass('btn-danger')
        codeMode = true

    }else {
        $('#all').removeClass('btn-info')
        $('#diff').removeClass('btn-danger')
        $('#diff').addClass('btn-info')
        $('#all').addClass('btn-danger')
        codeMode = false

    }
}
function showQuest() // 显示问题
{
    // rootEle.textContent = root_char[index[0]];
    rootEle.textContent = '加载中...';

    codeEle.textContent = "";

    inputEle.value = ""; // 清空输入框
    inputEle.focus()

    progressEle.value = (maxProgress + 1).toString();

    axios.get(host + '/dic/'+root_char[nowIndex]).then(res=>{
        nowOrdata = res.data.data
        rootEle.textContent = nowOrdata.org
        let templist = nowOrdata.code.split(' ')
        codeList = templist
        if(templist[1]) {
            ecode = templist[1]
        }
        if(templist[0]) {
            fcode = templist[0]
        }
        if(templist.length == 1) {
            fcode = templist[0]
        }else if (templist.length == 2) {
                ecode = templist[0]
                fcode = templist[1]
        }
        $('#input').attr('disabled',false);
    inputEle.focus()
    $('.box4').html(`<div class="title">查看拆分</div>`)
    $('.box4').removeClass('text-sm')
    $('.box3').html('<div class="title">查看编码</div>')
    $('.box3').removeClass('text-sm2')
    $('#cur').html(nowIndex+1)
    $('#all').html(total)
    progressEle.value = (nowIndex + 1).toString();
    progressEle.max = total.toString();
    })
}


